//	ID : pallab81
// 	PROG : 325
// 	LANG : C++
// 	2011-07-06-09.53.02 Wednesday
//
// 	"I have not failed, I have just found 10000 ways that won't work.
//


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>

using namespace std;

#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define mk make_pair
#define f first
#define s second

int cases,n;
int grid[100][100];
int mov[8][2]={{-1,0},{+1,0},{0,-1},{0,+1},{-1,-1},{-1,+1},{+1,-1},{+1,+1}};


inline void print(){
    int i,j;
    for(i=0;i<n;++i){
        for(j=0;j<n;++j){
            printf("%d ",grid[i][j]);
        }
        printf("\n");
    }
    bip;
}
inline void read(){
    int i,j;
    char ch;
    for(i=0;i<n;++i){
        for(j=0;j<n;++j){
            cin>>ch;
            grid[i][j]= (ch=='1' ? 1 : 0 ) ;
        }
    }
}
inline void fill(int r, int c){
    stack< pair<int,int> > st;
    st.push( mk(r,c) );
    grid[r][c]=0;

    while( st.empty()==false ){
        pair< int,int> peak = st.top();
        st.pop();
            for(int k=0;k<8;++k){
                int tr = peak.f+mov[k][0];
                int tc = peak.s+mov[k][1];
                    if(tr<0 || tc <0 || tr >=n || tc>=n )continue;
                    if( grid[tr][tc]==1){
                        st.push( mk(tr,tc) );
                        grid[tr][tc]=0;
                    }
            }
    }
}
inline void proc(){
    int i,j;
    int tot=0;
    for(i=0;i<n;++i){
        for(j=0;j<n;++j){
            if( grid[i][j]==1){
                fill( i , j);
                ++tot;
            }
        }
    }
    printf("Image number %d contains %d war eagles.\n",cases,tot);

}

int main(){
    cases=1;
    while( scanf("%d",&n)==1 ){
        read();
        proc();
        ++cases;
    }

return 0;
}

